<template>
	<view class="content" v-show="userinfo.is_mtuser_rz != 1">
		<view class="topmxx dis_f aic jub">
			<view class="dis_f aic jub left">

				<input type="text" placeholder="输入关键词搜索" placeholder-style="color:#bdbdbd" v-model="keywords">
				<text class="iconfont icon-sousuo cbd fs38"></text>

			</view>
			<view class=" cf fs30" @click="sousuo">
				搜索
			</view>
		</view>
		<view class="tabbox">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
				:duration="duration">
				<swiper-item v-for="(item,index) in bannimg" :key="index">
					<image :src="item.img" @click="bannercli(item)" mode="aspectFill" class="topimg"></image>
				</swiper-item>
			</swiper>
			<view class="mt20 dis_f aic " style="position: relative;">
				<u-notice-bar :text="text1" @click="natber" direction='column' bgColor="#F1F1F1"
					color="#626262"></u-notice-bar>

				<view class="gengd" @click="jump('/pagesA/in_advertisement/in_advertisement')">
					更多 >
				</view>
			</view>
			<view class="dis_f aic jub  mt30 ">
				<view class="dis_f fdc aic" @click="jump('/pagesA/in_text/in_text?type='+0)">
					<image src="/static/images/sm.png" mode="aspectFill" class="tabimg"></image>
					<view class="c6 fs30 mt10">
						使用说明
					</view>
				</view>
				<view class="dis_f fdc aic" @click="jump('/pagesA/in_promotion/in_promotion')">
					<image src="/static/images/tg.png" mode="aspectFill" class="tabimg"></image>
					<view class="c6 fs30 mt10">
						我的推广
					</view>
				</view>
				<view class="dis_f fdc aic" @click="jump('/pagesA/in_help/in_help')">
					<image src="/static/images/bmzx.png" mode="aspectFill" class="tabimg"></image>
					<view class="c6 fs30 mt10">
						帮助中心
					</view>
				</view>

				<button type="default" open-type="contact" style="height: 138rpx; line-height: 1.6;">
					<view class="dis_f fdc aic">
						<image src="/static/images/kf.png" mode="aspectFill" class="tabimg"></image>
						<view class="c6 fs30 mt10">
							联系客服
						</view>
					</view>
				</button>

			</view>
		</view>
		<swiper class="swiper ml30 mr30" circular :indicator-dots="indicatorDots" :autoplay="autoplay"
			:interval="interval" :duration="duration">
			<swiper-item v-for="(item,index) in imgbackguang" :key="index">
				<image :src="item.img" @click="bannercli(item)" mode="aspectFill" class="topimg"></image>
			</swiper-item>
		</swiper>
		<view class="dis_f aic juc ml30 mt30 ">
			<view class="fs36 cred">
				商品展示
			</view>
		</view>
		<view class="dis_f aic fww jub ml30 mr30" style="padding-bottom: 100rpx;">
			<view class="mianlist" v-for="(item,index) in list" :key="index"
				@click="jump('/pagesA/in_details/in_details?id='+item.id)">
				<image :src="item.img" mode="aspectFill" class="mianimg"></image>
				<view class="fs32 fwb  mt10 ml20">
					{{item.main_title}}
				</view>
				<view class="dis_f aic  mt10 ml20" v-if="item.goods_type != 2">

					<view class=" fs26 c6" style="text-decoration: line-through;">¥{{item.market_price}}</view>

				</view>
				<view class="dis_f aic jub  mt10 ml20 mr20 mb10">
					<view class="dis_f aic fwb" style="color: #e9121d;">
						<text class="fs24">￥</text>
						<text class="fs28">{{item.selling_price}}</text>
					</view>
					<view class="fs24" style="color: #f6b542;" v-if="item.goods_type == 1">
						送{{item.cpa}}积分
					</view>
					<view class="fs24" style="color: #f6b542;" v-if="item.goods_type == 2">
						送{{item.cps}}余额
					</view>
				</view>
			</view>
			<view class="dis_f juc aic w100 cac fs26" style="padding: 30rpx;" v-if="list.length == 0">
				暂无数据
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				bannimg: [],
				imgbackguang: [],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				text1: [],
				htmlhsowmxx: false,
				cid: '',
				keywords: '',
				type: '',
				page: 1,
				value1: 0,
				userinfo: "",
				gongg: ""
			}
		},
		onShow() {
			this.userinfo = uni.getStorageSync('userInfo') || ''

			this.postimg()
			this.postlist()
			this.postconfig()
			this.postimgs()


		},
		onLoad(option) {
			console.log(option.invite_id)
			uni.setStorageSync('invite_id', option.invite_id)
		},

		//发送给朋友
		onShareAppMessage(res) {
			// 此处的distSource为分享者的部分信息，需要传递给其他人
			return {
				title: '九淘',
				type: 0,
				path: '/pages/index/index?invite_id=' + this.userinfo.id,

			}
		},
		//分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '九淘',
				type: 0,
				path: '/pages/index/index?invite_id=' + this.userinfo.id,
			}
			// }
		},
		methods: {
			natber(name) {
				console.log(name)
				uni.navigateTo({
					url: '/pagesA/in_text/in_text?type=' + 2 + '&id=' + this.gongg[name].id
				})
			},
			bannercli(item) {
				if (this.userinfo == '') {
					// this.showxieyi = true
					uni.showToast({
						title: '请先登录',
						icon: "none"
					})
					uni.reLaunch({
						url: '/pages/my/my'
					})
					return false
				}
				if (item.c1 == 3) {
					uni.navigateTo({
						url: '/pagesA/webview/webview?url=' + item.c2
					})
					return
				}
				if (item.c1 == 1) {
					uni.switchTab({
						url: '/pages/shopping/shopping'
					})
					return
				}
				if (item.c1 == 2) {
					uni.navigateTo({
						url: '/pagesA/in_details/in_details?id=' + item.c2
					})
					return
				}
			},
			change1(e) {
				console.log('change1', e);
			},
			postimgs() {
				let that = this
				that.api.post('index/bannerlst', {
					type: 0
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.bannimg = res.data
					}


				})
			},
			postconfig() {
				let that = this
				that.api.post('index/newslst', {
					type: 0
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.gongg = res.data
						var shuzi = []
						for (let i = 0; i < res.data.length; i++) {
							shuzi[i] = res.data[i].title
						}
						console.log(shuzi)
						this.text1 = shuzi
					}


				})
			},
			postimg() {
				let that = this
				that.api.post('index/bannerlst', {
					type: 1
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.imgbackguang = res.data
					}


				})
			},
			postlist() {
				let that = this

				that.api.post('index/goodslst', {
					// page: this.page,
					// size: 10,
					type: 1,
					keywords: this.keywords,
					// cid: this.cid,
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.list = res.data
					}


				})
			},
			sousuo() {
				if (this.keywords == '') {
					uni.showToast({
						title: '请输入搜索内容',
						icon: "none"
					})
				} else {
					this.postlist()
				}
			},
			jump(url) {
				if (this.userinfo == '') {
					// this.showxieyi = true
					uni.showToast({
						title: '请先登录',
						icon: "none"
					})
					uni.reLaunch({
						url: '/pages/my/my'
					})
					return false
				}
				this.show = false
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.gengd {
		position: absolute;
		right: 0;
		top: 0;
		font-size: 26rpx;
		color: #feb746;
		background-color: #f1f1f1;
		height: 75rpx;
		line-height: 75rpx;
		padding: 0 20rpx;

	}

	button::after {
		border: none;
	}

	button {
		margin: 0;
		padding: 0;
		background-color: #fff !important;
	}

	.mianimg {

		width: 100%;
		height: 300rpx;
		background: #FFFFFF;
		border: 1px solid #F1F1F1;
		border-radius: 15rpx;
	}

	.mianlist {
		background: #FFFFFF;
		border: 1px solid #F1F1F1;
		border-radius: 15rpx;
		box-sizing: border-box;
		width: 48%;
		margin-top: 20rpx;
	}

	.icon-huo {
		color: #fe4d4d;
		font-size: 42rpx;
	}

	.tabimg {
		width: 82rpx;
		height: 82rpx;
		border-radius: 18rpx;
	}

	.tabbox {
		background-color: #fff;
		padding: 30rpx;
		box-sizing: border-box;
	}

	.topimg {
		width: 100%;
		height: 100%;

		border-radius: 15rpx;
	}

	.swiper {
		/* width: 92%; */
		height: 360rpx;

		border-radius: 15rpx;
	}

	input {
		font-size: 26rpx;
		width: 61%;
		height: 100%;
		line-height: 72rpx;
		color: #000;
	}

	.topmxx {
		background-color: #feb746;
		width: 100%;
		height: 150rpx;
		padding: 26rpx 30rpx;
		box-sizing: border-box;
	}

	.left {
		width: 80%;
		height: 72rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}
</style>